《Instant OpenCV for iOS》 学习笔记(1)

从iOS开始

本文简要介绍设置iOS开发环境以及运行一个“Hello World”程序。

准备

  1. 一台Mac OS X 台式机或笔记本
  2. iOS 设备(比如iphone)
  3. Xcode
  4. 这本书的例子程序源码,可以到http://www.packtpub.com/support注册然后会从邮箱收到源代码的下载链接。

步骤

  1. 在xcode创建新工程
    • 菜单栏:File -> new -> Project
    • 选择 Single View Application
    • 填写 Product Name (比如填写C01)
    • 选择 Language 为 Objective-C
    • 不要勾选 Use Core Data, Include Unit Tests,Include UI Tests
    • 按 Next 选择保存路径 然后finish 工程就建好了。
  2. 编译ViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Hello World!");

[[[UIAlertView alloc]
initWithTitle:@"喂,这里!"
message:@"欢迎来到Opencv开发社区!"
delegate:nil cancelButtonTitle:@"继续"
otherButtonTitles:nil, nil]
show];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
  1. 编译运行
    在emulator上看到结果
    1.png